class MyDataWithMethod(object):
    def printFoo(self):
        print('You invoked printFoo()')


class AddrBookEntry(object):
    def __init__(self, nm, ph):
        self.name = nm
        self.phone = ph
        print('Created instance for: %s' % self.name)

    def updatePhone(self, newph):
        self.phone = newph
        print('Update phone# for: %s' % self.name)


class EmplAddrBookEntry(AddrBookEntry):
    def __init__(self, nm, ph, id, em):
        AddrBookEntry.__init__(self, nm, ph)
        self.empid = id
        self.email = em

    def updateEmail(self, newem):
        self.email = newem
        print('Updated e-mail address for:', self.name)

class P(object):
    def __init__(self):
        print('call P constructor')
    def foo(self):
        print('Hi i am P-foo')




class C(P):
    def __init__(self):
        super(C, self).__init__()
        print('call C constructor')
    def foo(self):
        # P.foo(self)
        super(C, self).foo()
        print('Hi i am C-foo')


class RoundFloat(float):
    def __new__(cls, val):
        # return float.__new__(cls, round(val, 2))
        return super(RoundFloat, cls).__new__(cls, round(val, 2))

print(RoundFloat(1.8789))


class SortedKeyDict(dict):
    def keys(self):
        # return sorted(super(SortedKeyDict, self).keys())
        return sorted(dict.keys(self))


d = {'c': 1, 'b':2, 'a':3}
sd = SortedKeyDict(d)

print(d.keys())
print(sd.keys())




